<template>
	<view class="home">
		<!-- 未登录 -->
		<template v-if="islogin">
			<view class="uflex-a-j_c">登录仿糗事百科，体验更多功能</view>
			<!-- 第三方登录 -->
			<other-login></other-login>
			<!-- 账号密码登录 -->
			<view class="uflex-a-j_c" @tap="openLogin">
				账号密码登录 <view class="icon iconfont icon-jinru"></view>
			</view>
		</template>
		
		<!-- 登陆 -->
		<template v-else>
			<home-info :homeinfo="homeinfo"></home-info>
		</template>
		
		<!-- 数据 -->
		<home-data :homedata="homedata"></home-data>
		<!-- 广告位 -->
		<view class="home-adv uflex-a-j_c">
			<image src="../../static/demo/demo20.jpg" mode="widthFix" lazy-load></image>
		</view>
		<!-- 功能列表 -->
		<view class="home-list">
			<block v-for="(item, index) in list" :key="index">
				<home-list-item :item="item" :index="index" :isborder="true"></home-list-item>
			</block>
		</view>
	</view>
</template>

<script>
	import homeListItem from '../../components/home/home-list-item.vue';
	import homeInfo from '../../components/home/home-info.vue';
	import otherLogin from '../../components/home/other-login.vue';
	import homeData from '../../components/home/home-data.vue';
	export default {
		data() {
			return {
				islogin:true,
				homedata: [
					{
						name: '糗事',
						num: 0
					},
					{
						name: '动态',
						num: 0
					},
					{
						name: '评论',
						num: 0
					},
					{
						name: '收藏',
						num: 0
					}
				],
				homeinfo: {
					userpic:'../../static/demo/userpic/1.jpg',
					username:'昵称',
					totalnum:0,
					todaynum:0
				},
				list: [
					{
						icon: 'liulan',
						name: '浏览历史',
						clicktype: '',
						url:''
					},
					{
						icon: 'huiyuanvip',
						name: '糗百认证',
						clicktype: '',
						url:''
					},
					{
						icon: 'keyboard',
						name: '审核糗事',
						clicktype: '',
						url:''
					}
				]
			}
		},
		methods: {
			openLogin() {
				uni.navigateTo({
					url:'../login/login'
				})
			}
		},
		onNavigationBarButtonTap(ev) {
			if(ev.index === 0){
				uni.navigateTo({
					url:'../user-set/user-set',
					animationType:"slide-in-right"
				})
			}
		},
		components:{
			homeListItem,
			homeInfo,
			otherLogin,
			homeData
		}
	}
</script>

<style scoped lang="scss">
.home{
	.home-adv{
		padding: 20upx;
		image{
			border-radius: 20upx;
			height: 150upx;
		}
	}
	.home-list{
		padding: 20upx;
	}
}
</style>
